package com.jiandan.asm

import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes




/**
 * 防止快速点击
 */
class ASMClassVisitor extends ClassVisitor {

    private String className;

    ASMClassVisitor(ClassVisitor classVisitor) {
        super(Opcodes.ASM7, classVisitor)
    }


    @Override
    void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        super.visit(version, access, name, signature, superName, interfaces)
        this.className = name
    }

    @Override
    MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {

        def methodVisitor = cv.visitMethod(access, name, descriptor, signature, exceptions)
//        if (name == "onClick" && descriptor == "(Landroid/view/View;)V") {
//            return new FastMethodVisitor(api, methodVisitor, access, name, descriptor)
//        } else {
//            return methodVisitor
//        }

        return new ASMMethodAdapter(api, methodVisitor, access, name, descriptor, className)
    }


}
